Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make namespace configurable for anywhere resources #177

Merged
merged 5 commits into from
Sep 15, 2021

Conversation

taneyland
Copy link
Member

@taneyland taneyland commented Sep 10, 2021

Issue #, if available:

Description of changes:
This PR creates a namespace field in the clusterconfig for all "anywhere.eks.amazonaws.com" resources. This namespace is configurable, so the user can specify the name of the namespace to store these resources. If no namespace is specified, it will behave as it does currently & use the "default" namespace.

These changes were tested with the following cases (all cases had external etcd configured):

  • Create/Delete with Flux enabled

  • Upgrade with Flux enabled

  • Create/Delete without Flux

  • Upgrade without Flux

  • EKS-A controller still behaves as expected

  • Not specifying namespace still defaults to the "default" namespace

  • By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@danbudris
Copy link
Member

I might be missing it in all these files, but we should make sure that we prevent flux from modifying the namespace attribute of the cluster.

We've got the validation in the upgrade preflight check of immutable fields, but we'll want to add it to the immutable fields in the cluster webhook, as well

@vivek-koppuru
Copy link
Member

I might be missing it in all these files, but we should make sure that we prevent flux from modifying the namespace attribute of the cluster.

We've got the validation in the upgrade preflight check of immutable fields, but we'll want to add it to the immutable fields in the cluster webhook, as well

Since we are retrieving objects based on namespace, would change the namespace count as creating a new object instead, which would need to be blocked for the create rather than making that specific field immutable?

@@ -6,5 +6,6 @@ package v1alpha1
// and https://github.com/kubernetes-sigs/cluster-api/blob/bf790fc2a53614ff5d3405c83c0de0dd3303bb1f/api/v1alpha2/common_types.go#L67-L128
// as needed.
type ObjectMeta struct {
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to output the namespace as part of the generate command, so this isn't required right?

pkg/executables/kubectl.go Show resolved Hide resolved
@jaxesn jaxesn removed the next label Sep 13, 2021
@jaxesn jaxesn added this to the next milestone Sep 13, 2021
Copy link
Member

@vivek-koppuru vivek-koppuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall, but let's add a e2e test for this that specifies a different namespace from default and tests flux and upgrade.

@@ -20,6 +20,12 @@ func ValidateImmutableFields(ctx context.Context, k ValidationsKubectlClient, cl
return fmt.Errorf("cluster name is immutable")
}

if prevSpec.Namespace != spec.Namespace {
if !(prevSpec.Namespace == "default" && spec.Namespace == "") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have this same check for GitOps and OIDC? Or is this not the case because it would fail in validations earlier anyways? If that's the case, we technically don't need the checks above for VSphere if this check here covers it for all the config anyways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. These cases are covered in earlier validations. I removed the unnecessary checks

Copy link
Member

@vivek-koppuru vivek-koppuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@eks-distro-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feyyyyylo, taneyland, vivek-koppuru

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [taneyland,vivek-koppuru]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@eks-distro-bot eks-distro-bot merged commit 862d81a into aws:main Sep 15, 2021
@jaxesn jaxesn removed this from the next milestone Feb 1, 2022
@eks-distro-bot eks-distro-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants